<div id="header"><div>Dashboard</div></div><p>

<?php

// If not logged in, simply offer a link to the login page
if(!isset($_SESSION["loggedIn"]))
{
	echo "Please <a href=\"?p=loginform\">login</a>";
	return;
}

// Otherwise, we're logged in...
		
	// Write the username and offer a logout link
	echo '<div id="subheader">User</div><p>'.$_SESSION['username'].'<a id="sidelink" href="?p=loginform&action=logout">logout</a></p>';

	// Create an array of the theme files mapped to the visible name
	$themes = array();
	$themes["style_royal_panda.css"] = "Royal Panda";
	$themes["style_angry_tiger.css"] = "Angry Tiger";
	$themes["style_retro_zebra.css"] = "Retro Zebra";
  $themes["style_nonplussed_platypus.css"] = "Nonplussed Platypus";
  $themes["style_disillusioned_duck.css"] = "Disillusioned Duck";
  $themes["style_lamentable_leopard.css"] = "Lamentable Leopard";
  $themes["style_cynical_cardinal.css"] = "Cynical Cardinal";
	$themes["style_amiable_anteater.css"] = "Frosty The Snowman";

	// Create subheader
	echo '<div id="subheader">Theme</div>';

	// Create theme selection form
	echo '<form method="post">';
	echo 'Theme: ';
	echo '<select name="theme" id="theme">';

	// Go through themes and add options to form
	unset($output);
	foreach($themes as $themeFile=>$themeName)
	{
		$output = $output.'<option value="'.$themeFile.'"';

		// If the currently selected theme is this one, add the "selected" attribute to make it currently selected in the dropmenu
		if($_SESSION['theme'] === $themeFile)
		{
			$output = $output.' selected="selected"';
		}

		$output = $output.'>'.$themeName.'</option>';

	}

	// Output our dropbox elements
	echo $output;

	// Add apply button and end the form
	echo '</select>
				<p class="submit"><input type="submit" value="Apply" /></p>		
				</form>';
	
	//
	// The following adds a shortened help message regarding the current page to the sidebar,
	// and a link to the more complete help page
	//
	echo '<br/>';
	echo '<div id="subheader">Help</div>';
	
	unset($output);
	
	// Grab the currently viewed page from the URL
	$curpage = get_page_of_params($_SERVER['REQUEST_URI']);

	// Depending on the current page, add some small help information
	switch($curpage)
	{
		case "home":
			$output = "<p>This provides basic information about iRoomMonitor</p>";	
			break;
		case "help":
			$output = "<p>This page provides a helpful description about the page you were viewing</p>";
			break;
		case "sensormanagement":
			$output = '<p>This page shows helpful information about your sensors.</p>';
			break;
		case "timeforms":
			$output = '
				<p>This page lets you view a sensor\'s data over a specified interval</p>
				';
			break;
		case "recentdata":
			$output = '
				<p>This page lets you view the most recent data from any sensor.</p>
				';
			break;
		case "privacy":
			$output = "iRoomMonitor's privacy policy.";
			break;
		case "settings":
			$output = '<p>Register your phone number for SMS updates on room status</p>';
			break;
		default:
			$output = "";
			break;
			
	}
	echo $output;

	// Offer a link to get more help
	echo '<a href="?p=help">more help</a>';

?>
</p>
